#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
struct ListNode {
      int val;
      struct ListNode *next;
};

struct ListNode* reverseList(struct ListNode* head) {
    if (head == NULL)
        return NULL;
    struct ListNode* str1 = NULL;
    struct ListNode* str2 = head;
    struct ListNode* str3 = str2->next;
    while (str2)
    {
        str2->next = str1;
        str1 = str2;
        str2 = str3;
        if (str3)
            str3 = str3->next;
    }
    return str1;
}